home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / ViewIt™ 2.24 Shareware / FaceWare / FaceWare.rsrc / TEXT_1314_BC4. Btn, Chk, & Rad.txt < prev    next >
Text File  |  1994-04-10  |  5KB  |  31 lines

  1. Buttons and Check Boxes
  2.   "Button", "Check Box", and "Radio Button" types are set up in the same way as "Static" non-text controls (see previous topic), making similar use of STR#, PICT, ICON, SICN, cicn, PAT , PAT#, CURS, acur, and clut resources.  They differ, however, in the role played by the control's Min, Max, and Value.
  3.  
  4. Control States
  5.   Check boxes and radio buttons can be in any one of four distinct control "states":
  6.   1. unchecked, unhilited
  7.   2. unchecked, hilited  (when clicked)
  8.   3. checked, hilited  (when clicked)
  9.   4. checked, unhilited
  10. Buttons can only be in states 1 & 2 (never checked).
  11.   For buttons, check boxes, and radio buttons that are not linked to resource lists, the control Min should be set to 0, Max to 1, and Value to 0 (unchecked) or 1 (checked).  When such controls are clicked, BaseCt hilites the control (using inversion, color switching, or dimming), and ViewBV (the view driver) checks or unchecks check boxes and radio buttons after the mouse is released.
  12.   For buttons, check boxes, and radio buttons linked to true resource lists (SICN, PAT#, acur, or clut) set Min = 0, Max = index of resource to display, and Value = 0 (unchecked) or Value = Max (checked) to have hiliting/checking displayed by inversion, color switching, or dimming.
  13.   Alternatively, controls linked to resource lists, or a range of resources, or STR# lists containing a list of resources can use different resources to display each control state.  To do this, set the control's Min to a value corresponding to the unchecked state, and Max to a value corresponding to the checked state (or to a button's hilited state).  If the Min and Max differ by more than 1, and the control is not a button, then intermediate values are also used for the hilite states.
  14.   For example, if a check box control is linked to an SICN small icon list, with Min = 4 and Max = 7, then the icons displayed for each state would be:
  15.   1. SICN #4 = unchecked, unhilited
  16.   2. SICN #5 = unchecked, hilited
  17.   3. SICN #6 = checked, hilited
  18.   4. SICN #7 = checked, unhilited
  19. Alternatively, if Min = 4 and Max = 5, then,
  20.   1. SICN #4 = unchecked, unhilited
  21.   4. SICN #5 = checked, unhilited
  22. and inversion, color switching, or dimming would be used to display hilite states.  This scheme provides a very simple way to create custom button, check box, and radio controls without requiring a single line of code to be written.
  23.   Display Note:  If the resource type linked to a check box or radio button is solid (i.e., completely replaces itself when drawn), then you can reduce "flashing" during checking and hiliting by making the control transparent (i.e., don't check "Solid Body" in Style menu).  The "Shaded...(cicn)" check box controls, for example, are transparent since they are based on cicn resources that replace each other when drawn. The "Standard Mimic (SICN)" check box, however, was given a solid body since SICNs do not completely overwrite one another when the checked or hilite state is changed.
  24.  
  25. Options
  26.   VarCode options 16, 32, and 64 described in the previous topic also apply to buttons, check boxes, and radio buttons.  Two additional options are supported:
  27. ‚Ä¢ Bit value 128 can be added to the VarCode of button-type controls to indicate that a click in the button should continuously return messages to the program while the button remains pressed (vs. sending one message when the button is released).  The example "Arrows (SICN)" controls illustrate such buttons and are also used in the "vDemoXY" example program.  (This option assumes that "Return on Hit" is checked in the Control dialog.)
  28. ‚Ä¢ Bit value 4096 can be added to the VarCode to indicate that "dimming" should be used instead of inversion or switching colors to hilite the control.  See "Hilited Appearance" under "Overview" for a complete discussion of hilite options.
  29.  
  30. Data Linking
  31.   Check box and radio button controls can be linked to program variables (see "Data Links" in the ViewIt Guide for more info on data linking).  Data links are based on the relationship between the current control Value and the control Min & Max.  If Value = Min, then 0 is returned by GetVal.  If Value = Max, then 1 is returned by GetVal.  Similarly, if 0 is passed to BaseCt by SetVal, then Value is set to Min.  If 1 is passed by SetVal, then Value is set to Max.  What this means is that a program always "sees" check boxes and radio buttons as having "values" of zero or one, and never needs to worry about how the control's Min, Max, and Value are being used.